import request from '@/utils/request'

/**
 *  获取商品列表
 * @return {*}
 */
export const getGoodsListApi = () => {
  return request({
    url: '/product',
    method: 'get'
  })
}

/**
 * 获取购物车列表
 * @param uid
 * @return {*}
 */
export const getShoppingCartApi = (uid) => {
  return request({
    url: `/product/shop/${uid}`,
    method: 'get'
  })
}

/**
 *  搜索商品
 * @param proMess
 * @return {*}
 */
export const searchGoodsApi = (proMess) => {
  return request({
    url: `/product/search`,
    method: 'get',
    params: proMess
  })
}

/**
 *  获取商品详情
 * @param proId 商品id
 */
export const getGoodsDetailApi = (proId) => {
 return request({
   url:`/product/${proId}`,
   method: 'get'
 })
}

export const updateGoodsApi = (goods) => {
  return request({
    url: `/product/update/${goods.proId}`,
    method: 'put',
    data: goods
  })
}

/**
 *  添加商品
 * @param goods
 * @return {*}
 */
export const addGoodsApi = (goods) => {
  return request({
    url: `/product/`,
    method: 'post',
    data: goods
  })
}